package com.freesun.springboot.web.hikari;

import com.zaxxer.hikari.HikariDataSource;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

/**
 * @author yangfei
 * @date 2018/3/9 16:52
 */
@Configuration
public class HikariAutoConfiguration {


    @Bean(name = "hikariDataSource")
    @Qualifier("hikariDataSource")
    @ConfigurationProperties(prefix = "spring.datasource")
    public DataSource hikariDataSource() {
        return DataSourceBuilder.create().type(HikariDataSource.class).build();
    }

}
